package com.ewzj.bigdata.mvp.ui.activity

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle

import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.extensions.initcolor
import com.ewzj.bigdata.di.component.DaggerScanRecordActivityComponent
import com.ewzj.bigdata.di.module.ScanRecordActivityModule
import com.ewzj.bigdata.mvp.contract.ScanRecordActivityContract
import com.ewzj.bigdata.mvp.presenter.ScanRecordActivityPresenter
import com.jakewharton.rxbinding2.view.RxView
import com.jess.arms.base.BaseActivity
import com.jess.arms.di.component.AppComponent
import kotlinx.android.synthetic.main.activity_news_web.*
import kotlinx.android.synthetic.main.activity_scan_record.*

class ScanRecordActivity : BaseActivity<ScanRecordActivityPresenter>(),ScanRecordActivityContract.View {
    override fun initView(savedInstanceState: Bundle?): Int {
        return R.layout.activity_scan_record
    }

    override fun setupActivityComponent(appComponent: AppComponent?) {
        DaggerScanRecordActivityComponent.builder().appComponent(appComponent)
                .scanRecordActivityModule(ScanRecordActivityModule(this))
                .build()
                .inject(this)
    }

    override fun initData(savedInstanceState: Bundle?) {
        initlistener()
        swipeRefreshLayout.initcolor()
        mPresenter.initAdapter(rv_content)
        swipeRefreshLayout.setOnRefreshListener { mPresenter.loadScanRecord() }
        mPresenter.loadScanRecord()

    }

    private fun initlistener() {
        tv_title.text="浏览记录"
        RxView.clicks(iv_back).subscribe({finish()})
    }

    override fun showLoading() {
        swipeRefreshLayout.isRefreshing=true
    }

    override fun launchActivity(intent: Intent?) {
    }

    override fun hideLoading() {
        swipeRefreshLayout.isRefreshing=false
    }

    override fun killMyself() {
    }

    override fun showMessage(message: String?) {
    }


}
